package com.leetcode.LC;

public class LC1422 {
    public int maxScore(String s) {

        int rs = 0, one = 0, zero = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                one++;
            }
        }

        for (int i = 0; i < s.length()-1; i++) {
            if (s.charAt(i) == '1') {
                one--;
            } else {
                zero++;
            }
            rs = Math.max(rs, one + zero);
        }
        return rs;
    }

    public static void main(String[] args) {
        System.out.println(new LC1422().maxScore("1111"));
    }
}
